<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>7-结构伪类选择器</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        li{
            list-style: none;
        }
        /* 排序从1开始 */
        /* 抓第一个元素 */
        .box li:first-child{
            color: red;
        }
        .box li:last-child{
            color: blue;
        }
        /* 抓取某一个 */
        .box li:nth-child(2){
            color: orange;
        }
        /* 倒数第2个 */
        .box li:nth-last-child(2){
            color: pink;
        }
    </style>
</head>
<body>
    <!-- 
        结构伪类选择器：
            nth-child
     -->
    <ul class="box">
        <li>百度</li>
        <li>抖音</li>
        <li>腾讯</li>
        <li>新浪</li>
    </ul>

    <style>
        p.list a:nth-child(2n){
            color: red;
        }
        p.list a:nth-child(2n+1){
            color: blue;
        }
    </style>
    <p class="list">
        <a href="">西安</a>
        <a href="">西宁</a>
        <a href="">太原</a>
        <a href="">成都</a>
    </p>

    <hr>
    <style>
        /* 找到前2个 */
        p.content a:nth-child(-n+2){
            color: green;
        }
        /* 从第3个以后 */
        p.content a:nth-child(n+3){
            color: brown;
        }
    </style>
    <p class="content">
        <a href="">广州</a>
        <a href="">香港</a>
        <a href="">厦门</a>
        <a href="">青岛</a>
        <a href="">燕山</a>
        <a href="">石家庄</a>
    </p>
    <hr>
    <!-- 
        结构伪类选择器
        nth-of-type
     -->
    <style>
        footer a:nth-of-type(1){
            color: red;
        }
        footer a:nth-of-type(4){
            color: green;
        }
    </style>
    <footer>
        <a href="">广州</a>
        <a href="">香港</a>
        <a href="">厦门</a>
        <a href="">青岛</a>
        <a href="">燕山</a>
        <a href="">石家庄</a>
    </footer>
</body>
</html>